/*
* ICholesky.cs
* 
* Copyright (c) 2006, dnAnalytics. All rights reserved.
*/

using System;
using dnAnalytics.Math;
using dnAnalytics.Exceptions;
namespace dnAnalytics.LinearAlgebra.Decomposition
{
    ///<summary>Interface to compute the Cholesky factorization of a n by n <see cref="Matrix"/>.</summary>
    internal interface ICholesky : IAlgorithm
    {
        /// <summary>Return a value indicating whether the matrix is positive definite.</summary>
        /// <returns><b>true</b> if the matrix is positive definite; otherwise, <b>false</b>.</returns>
        bool IsPositiveDefinite();

        /// <summary>Returns the Cholesky factored matrix (lower triangular form).</summary>
        /// <returns>The lower triangular Cholesky factored matrix.</returns>
         Matrix Factor();

        /// <summary>
        /// Copies the Cholesky factored matrix (lower triangular form) into the result <see cref="Matrix"/>.
        /// </summary>
        /// <param name="result">The <see cref="Matrix"/> store factored matrix into.</param>
        void Factor(Matrix result);

        /// <summary>Calculates the determinant of the matrix.</summary>
        /// <returns>The determinant of the matrix.</returns>
        double Determinant();

        /// <summary>
        ///  Solves a system of linear equations, <b>AX = B</b>.
        /// </summary>
        /// <param name="rightHandSide">The right hand side <see cref="Matrix"/>, <b>B</b>.</param>
        /// <returns>The left hand side <see cref="Matrix"/>, <b>X</b>.</returns>
        Matrix Solve(Matrix rightHandSide);

        /// <summary>
        /// Solves a system of linear equations, <b>AX = B</b>.
        /// </summary>
        /// <param name="rightHandSide">The right hand side <see cref="Matrix"/>, <b>B</b>.</param>
        /// <param name="result">The left hand side <see cref="Matrix"/>, <b>X</b>.</param>
        void Solve(Matrix rightHandSide, Matrix result);

        /// <summary>
        /// Solves a system of linear equations, <b>Ax = b</b>.
        /// </summary>
        /// <param name="rightHandSide">The right hand side vector, <b>b</b>.</param>
        /// <returns>The left hand side <see cref="Vector"/>, <b>x</b>.</returns>
        Vector Solve(Vector rightHandSide);

        /// <summary>
        /// Solves a system of linear equations, <b>Ax = b</b>.
        /// </summary>
        /// <param name="rightHandSide">The right hand side <see cref="Vector"/>, <b>b</b>.</param>
        /// <param name="result">The left hand side <see cref="Vector"/>, <b>x</b>.</param>
        void Solve(Vector rightHandSide, Vector result);
    }
}
